package com.jic.interaction.weUM.controller;

import com.alibaba.fastjson.JSON;
import com.jic.interaction.weUM.common.utils.RestResult;
import com.jic.interaction.weUM.service.UserAuthenticationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName userAuthenticationController
 * TODO
 * @Description 用户登录认证
 * @Author chenhongfeng
 * @Date 2020/11/11 14:02
 * @Version 1.0
 **/
@Slf4j
@RestController
@RequestMapping("/user")
@Api(value = "用户登录认证", tags = "用户登录认证", description = "UserAuthenticationController")
public class UserAuthenticationController {

    @Autowired
    UserAuthenticationService userAuthenticationService;

    /*
     * @Author chengpunan
     *@Package com.jic.interaction.weUM.controller
     *ClassName UserAuthenticationController
     * @Description  //TODO
     * @Date 14:10 2020/11/11
     * @Param userId userPwd
     * @return RestResult
     * @Version:1.0
     **/
    @ApiOperation(value = "用户登录认证", notes = "用户登录认证。")
    @GetMapping("/login")
    public RestResult login(String userId,String userPwd) {
        log.info("进入了 入参{}" , JSON.toJSONString(userPwd));
        RestResult login = userAuthenticationService.login(userId, userPwd);
        if(login.getCode()=="0"){
            return RestResult.success("0000",login);
        }
        return RestResult.error(login.getCode(),login.getMsg());
    }
}
